{// 引入标签库 }
<tagLib name="html" />
<include file="Public:header" />
<div class="main">
    <div class="main_title">{%EDIT} <a href="{:u("Xiacai/index")}" class="back_list">{%BACK_LIST}</a></div>
    <div class="blank5"></div>
    <form name="edit" action="__APP__" method="post" enctype="multipart/form-data">
        <table class="form" cellpadding=0 cellspacing=0>
            <tr>
                <td colspan=2 class="topTd"></td>
            </tr>
            <tr>
                <td class="item_title">节目名称:</td>
                <td class="item_input"><input type="text" class="textbox require" name="subject" value="{$vo.subject}" /></td>
            </tr>
            <tr>
                <td class="item_title">节目简介:</td>
                <td class="item_input"><textarea name="desc" class="textarea require">{$vo.desc}</textarea></td>
            </tr>
            <tr>
                <td class="item_title">规则介绍:</td>
                <td class="item_input"><textarea name="rule_intro" class="textarea require" style="height:60px;">{$vo.rule_intro}</textarea></td>
            </tr>
            <tr>
                <td class="item_title">节目图标:</td>
                <td class="item_input"><html:imgUpload name = 'ico_url' id='ico_url' value="$vo.ico_url" /><span class='tip_span'></span></td>
            </tr>
            <tr>
                <td class="item_title">节目封面:</td>
                <td class="item_input"><html:imgUpload name = 'image_url' id='image_url' value="$vo.image_url" /><span class='tip_span'></span></td>
            </tr>
            <tr>
                <td class="item_title">开播时间提示:</td>
                <td class="item_input"><input type="text" class="textbox require" name="start_time_tip" size="45" value="{$vo.start_time_tip}" /> 例如：每周一、三12:00和周日21:30</td>
            </tr>
            <!-- 2017-10-27 弃用,需求不需要这么复杂，自己搞复杂了 -->
            <tr>
                <td class="item_title">开播时间:</td>
                <td class="item_input">
                    <select name="start_cycle" required="required" data-value="{$vo.cycle}">
                        <option value="">==选择==</option>
                        <option value="week">每周</option>
                        <option value="day">每天</option>
                    </select>
                    <span id="cycle-detail"></span>
                </td>
            </tr>
            <tr>
                <td class="item_title">主持人ID:</td>
                <td class="item_input"><input type="text" class="textbox require" name="host_user_ids" value="{$vo.host_user_ids}" size="45" />多个主持人ID之间以空格隔开</td>
            </tr>
            <tr>
                <td class="item_title">主播ID:</td>
                <td class="item_input"><input type="text" class="textbox require" name="user_id" value="{$vo.user_id}" />开直播房间的主播ID</td>
            </tr>
            <tr>
                <td class="item_title">排序:</td>
                <td class="item_input"><input type="text" class="textbox" name="sort" value="{$vo.sort}" /></td>
            </tr>
            <tr>
                <td class="item_title"></td>
                <td class="item_input">
                    <!--隐藏元素-->
                    <input type="hidden" name="{:conf('VAR_MODULE')}" value="Xiacai" />
                    <input type="hidden" name="{:conf('VAR_ACTION')}" value="update" />
                    <input type="hidden" name="id" value="{$vo.id}" />
                    <input type="hidden" name="airtime_sign" value='{$airtime_sign}' />
                    <!--隐藏元素-->
                    <input type="submit" class="button" value="{%EDIT}" />
                    <input type="reset" class="button" value="{%RESET}" />
                </td>
            </tr>
            <tr>
                <td colspan=2 class="bottomTd"></td>
            </tr>
        </table>
    </form>
    <script>
        // 开播时间周期切换 2017-9-29
        $('[name="start_cycle"]').change(function () {
            var cycle = $(this).val();
            cycle_change_fn(cycle);
        })
        $('#cycle-detail').delegate(':checkbox', 'click', function () {
            $(this).next().toggle();
        })
        // 选中开播周期
        $('[name="start_cycle"] option[value="{$vo.start_cycle}"]').prop('selected', true);
        cycle_change_fn('{$vo.start_cycle}', {$airtime})
        // 2017-9-30
        function cycle_change_fn(cycle, airtime) {
            var inputs = '';
            var start_time = '';
            var checked = '';
            switch (cycle) {
                case 'week':
                    var weekdays = ['天', '一', '二', '三', '四', '五', '六'];
                    var n = 0;
                    for (var i = 1; i <= 7; i++) {
                        n = i;
                        if (n > 6) {
                            n = 0;
                        }
                        start_time = '';
                        checked = '';
                        if (airtime) {
                            for (var iairtime in airtime) {
                                if (airtime[iairtime].weekday == n) {
                                    checked = ' checked="checked"';
                                    start_time = airtime[iairtime].start_time;
                                }
                            }
                        }
                        inputs += '<span><input type="checkbox" name="weekday[]" value="' + n + '"' + checked + ' />' + weekdays[n] + '<span ' + (checked ? '' : ' style="display:none"') + '><input type="text" name="start_time' + n + '" class="textbox" placeholder="HH:mm" size="4" value="' + start_time + '" /></span></span> ';
                    }
                    break;
                case 'day':
                    if (airtime) {
                        start_time = airtime[0].start_time;
                    }
                    inputs = '<input type="text" name="start_time" class="textbox" placeholder="HH:mm" size="4" value="' + start_time + '" />';
                    break;
            }
            $('#cycle-detail').html(inputs);
        }
    </script>
</div>
<include file="Public:footer" />